import 'package:json_annotation/json_annotation.dart';

import '../../../util/DateUtil.dart';
import '../base/Req.dart';
import 'Message.dart';
import 'PullData.dart';
import 'PullData2.dart';

part 'SendData.g.dart';

class GroupReq extends Req {
  String groupId;

  GroupReq({required this.groupId});
}

 class GroupCreateReq extends GroupReq {
   String groupName;
   String? groupDesc;
   List<String> userIdSet;

  GroupCreateReq({required this.groupName, required this.userIdSet, required super.groupId});

  factory GroupCreateReq.fromJson(Map<String, dynamic> map) =>_$GroupCreateReqFromJson(map);

  Map<String, dynamic> toJson() => _$GroupCreateReqToJson(this);
}

class GroupAddReq extends GroupCreateReq {
  Map<String, String>? groupInfo;

  GroupAddReq({required super.groupName, required super.userIdSet, required super.groupId});

  factory GroupAddReq.fromJson(Map<String, dynamic> map) =>_$GroupAddReqFromJson(map);

  Map<String, dynamic> toJson() => _$GroupAddReqToJson(this);
}

class GroupExitReq extends GroupReq {
  List<String> userIdSet;

  GroupExitReq({required this.userIdSet, required super.groupId});

  factory GroupExitReq.fromJson(Map<String, dynamic> map) =>_$GroupExitReqFromJson(map);

  Map<String, dynamic> toJson() => _$GroupExitReqToJson(this);
}

class GroupDelReq extends GroupReq {

  GroupDelReq({required super.groupId});

  factory GroupDelReq.fromJson(Map<String, dynamic> map) =>_$GroupDelReqFromJson(map);

  Map<String, dynamic> toJson() => _$GroupDelReqToJson(this);
}

class GroupInfoReq extends GroupReq {
  GroupInfoReq({required super.groupId});

  Map<String, dynamic> toJson() => _$GroupInfoReqToJson(this);
}

class ServerSendGroupInfoReq extends ServerReq {
  GroupInfoItem groupInfoItem;

  ServerSendGroupInfoReq({required this.groupInfoItem});

  factory ServerSendGroupInfoReq.fromJson(Map<String, dynamic> map) =>_$ServerSendGroupInfoReqFromJson(map);

  Map<String, dynamic> toJson() => _$ServerSendGroupInfoReqToJson(this);
}

class MessageReadReq extends Req {
  List<String> messageIds;

  MessageReadReq({required this.messageIds});

  factory MessageReadReq.fromJson(Map<String, dynamic> map) =>_$MessageReadReqFromJson(map);

  Map<String, dynamic> toJson() => _$MessageReadReqToJson(this);
}

class MessageWithdrawReq extends Req {
  List<String> messageIds;

  MessageWithdrawReq({required this.messageIds});

  factory MessageWithdrawReq.fromJson(Map<String, dynamic> map) =>_$MessageWithdrawReqFromJson(map);

  Map<String, dynamic> toJson() => _$MessageWithdrawReqToJson(this);
}

class MessageDeleteReq extends Req {
  List<String> messageIds;

  MessageDeleteReq({required this.messageIds});

  factory MessageDeleteReq.fromJson(Map<String, dynamic> map) =>_$MessageDeleteReqFromJson(map);

  Map<String, dynamic> toJson() => _$MessageDeleteReqToJson(this);
}

class FileUploadSuccessReq extends Req {
  String messageId;

  FileUploadSuccessReq({required this.messageId});

  factory FileUploadSuccessReq.fromJson(Map<String, dynamic> map) =>_$FileUploadSuccessReqFromJson(map);

  Map<String, dynamic> toJson() => _$FileUploadSuccessReqToJson(this);
}

@JsonSerializable()
class DataChangeReq extends Req {
  DataType type;
  DataSubType subType;
  String key;
  String value;

  DataChangeReq({required this.type, required this.subType, required this.key, required this.value});

  factory DataChangeReq.fromJson(Map<String, dynamic> map) =>_$DataChangeReqFromJson(map);

  Map<String, dynamic> toJson() => _$DataChangeReqToJson(this);
}

@JsonSerializable()
class CollectCreateReq extends Req {
  List<CollectInfoItem> collectInfoItems;

  CollectCreateReq({ required this.collectInfoItems });

  factory CollectCreateReq.fromJson(Map<String, dynamic> map) =>_$CollectCreateReqFromJson(map);

  Map<String, dynamic> toJson() => _$CollectCreateReqToJson(this);
}

class DelReq extends Req {
  String serverId;

  DelReq({ required this.serverId});

  factory DelReq.fromJson(Map<String, dynamic> map) =>_$DelReqFromJson(map);

  Map<String, dynamic> toJson() => _$DelReqToJson(this);
}

class PingReq extends Req {

  PingReq();

  factory PingReq.fromJson(Map<String, dynamic> map) =>_$PingReqFromJson(map);

  Map<String, dynamic> toJson() => _$PingReqToJson(this);
}

class PongResp {

  PongResp();

  factory PongResp.fromJson(Map<String, dynamic> map) =>_$PongRespFromJson(map);

  Map<String, dynamic> toJson() => _$PongRespToJson(this);
}

enum DataType {
  group(1, "群"),
  session(2, "会话"),
  groupUser(3, "群组员");

  final int value;
  final String desc;

  const DataType(this.value, this.desc);
}

enum DataSubType {
  g_ed_name,
  g_ed_desc,
  s_ed_disturb,
  s_ed_top,
  gu_ed_userName,
  gu_ed_showName,
  ;
}

enum CollectStatus {
  enable(1, "可用"),
  disable(2, "不可用"),
  ;

  final int value;
  final String desc;

  const CollectStatus(this.value, this.desc);
}
